/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.NoteManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class DeleteNote extends AbstractAction
/*    */ {
/* 24 */   private static Logger logger = Logger.getLogger(DeleteNote.class.getName());
/*    */ 
/* 26 */   private int id = 0;
/*    */ 
/*    */   public DeleteNote(AbstractHttpServlet servlet) {
/* 29 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public DeleteNote(AbstractHttpServlet servlet, String id) {
/* 33 */     super(servlet);
/* 34 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response) throws IOException
/*    */   {
/* 39 */     User loginUser = super.getLoginUser(request);
/* 40 */     if (!loginUser.isAdmin)
/*    */     {
/* 42 */       super.showErrorMessage(response, "您没有修改该备注的权限");
/* 43 */       return;
/*    */     }
/*    */ 
/* 46 */     NoteManager manager = new NoteManager();
/*    */     try {
/* 48 */       int result = manager.delete(this.id);
/* 49 */       if (result > 0) {
/* 50 */         response.setContentType("text/html;charset=utf-8");
/* 51 */         PrintWriter out = response.getWriter();
/* 52 */         JSONObject jsonObject = new JSONObject();
/* 53 */         jsonObject.put("error", "0");
/* 54 */         jsonObject.put("result", Integer.valueOf(result));
/* 55 */         out.println(jsonObject);
/* 56 */         out.flush();
/* 57 */         out.close();
/* 58 */         return;
/*    */       }
/*    */     } catch (DBException e) {
/* 61 */       logger.warn("delete note failed", e);
/*    */     } catch (SQLException e) {
/* 63 */       logger.warn("delete note failed", e);
/*    */     }
/* 65 */     super.showErrorMessage(response, "备注删除失败，请稍后重试");
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.DeleteNote
 * JD-Core Version:    0.6.1
 */